package homework;

import java.util.Scanner;

public class PrimeNumbers_rangeAB {
	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);

	        // ---------------------Begin------------------------

	        // 获取输入的两个整数
	        int a = scan.nextInt();
	        int b = scan.nextInt();

	        // 确定范围的起始和结束
	        int start = Math.min(a, b);
	        int end = Math.max(a, b);

	        // 构建输出字符串
	        StringBuilder result = new StringBuilder();
	        result.append(start).append("到").append(end).append("之间的素数有：\n");

	        boolean found = false;
	        for (int num = start; num <= end; num++) {
	            if (isPrime(num)) {
	                result.append(num).append(" ");
	                found = true;
	            }
	        }
	        if (found) {
	            System.out.println(result.toString().trim());
	        } else {
	            System.out.println(start + "到" + end + "之间有:");
	        }
	        // ---------------------End------------------------
	    }

	    // 判断一个数是否为素数
	    public static boolean isPrime(int num) {
	        if (num <= 1) {
	            return false;
	        }
	        if (num == 2) {
	            return true;
	        }
	        if (num % 2 == 0) {
	            return false;
	        }
	        for (int i = 3; i <= Math.sqrt(num); i += 2) {
	            if (num % i == 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	        // ---------------------End------------------------
	}
